<template>
  <div>
    <button @click="save">save</button>
  </div>
</template>

<script>
import html2canvas from 'html2canvas'
export default {
    name: 'HeaderPage',
    setup() {
        const save = () => {
            const realHtml = document.getElementById('canvas-page')// 需要截图的包裹的（原生的）DOM 对象
            html2canvas(realHtml, {
                background: 'transparent',
                allowTaint: false,
                useCORS: true,
                taintTest: true,
                imageTimeout: 2000,
                width: realHtml.clientWidth,
                height: realHtml.clientHeight
            }).then(res => {
                console.log(res.toDataURL())
            }).catch(err => {
                console.log(err)
            })
        }
        return {
            save
        }
    }
}
</script>

<style scoped>

</style>
